{% load comments i18n crispy_forms_tags fluent_comments_tags staticfiles %}

{% if not form.target_object|comments_are_open %}
    <p>{% trans "Comments are closed." %}</p>
{% else %}
  {% if not form.helper or not form.helper.form_tag %}
    <form id="comment-form-{{ form.target_object.pk }}" data-object-id="{{ form.target_object.pk }}" action="{% comment_form_target %}" method="post" class="{% block form_class %}{{ form.helper.form_class|default:'js-comments-form comments-form form-horizontal' }}{% endblock %}"
          data-ajax-action="{% url 'comments-post-comment-ajax' %}">
      {% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
  {% endif %}

      {% block comment_form %}
        {% block form_fields %}
          {% crispy form %}
        {% endblock %}
          <script type="text/javascript">
          $(document).ready(function () {
              $asterisk = "<span class=\"asteriskField\">*</span>";
              $('#div_id_name label').html('{% trans "Name" %}'+$asterisk);
              $('#div_id_email label').html('{% trans "Email" %}'+$asterisk);
              $('#div_id_comment label').html('{% trans "Comment" %}'+$asterisk);
          })
          </script>
        {% block form_actions %}
          {% if not form.helper.inputs %}
            <div>
              <div class="col-sm-offset-2 col-sm-10">
                  <button type="submit" name="post" class="btn btn-primary">{% trans 'Submit' %}</button>
                {% ajax_comment_tags for form.target_object %}
                  <div class="clear"></div>
              </div>
            </div>
          {% else %}
            {% ajax_comment_tags for form.target_object %}
          {% endif %}
        {% endblock %}
      {% endblock %}

  {% if not form.helper or not form.helper.form_tag %}
    </form>
  {% endif %}
{% endif %}
